package com.hzbank.juc.review;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @description:
 * @author: libugu@cskaoyan.com
 * @date 2023/12/26 - 18:59
 */
@Slf4j
public class Test004 {
    public static void main(String[] args) throws InterruptedException {
        log.debug("开始运行...");
        Thread t1 = new Thread(() -> {
            log.debug("开始运行...");
            try {
                TimeUnit.SECONDS.sleep(2);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            log.debug("运行结束...");
        }, "daemon");
// 设置该线程为守护线程
        t1.setDaemon(true);
        t1.start();
        Thread.State state = t1.getState();

        TimeUnit.SECONDS.sleep(1);
        log.debug("运行结束...");
    }
}
